<template>
  <div style="background-color:#fff;padding:10px 20px;">
    <span style="line-height:60px;font-size:20px;">用户反馈</span>

    <!-- 医生表格卡片 -->
    <el-card style="margin: 20px;">
      <el-table :data="feedBackArr">
        <el-table-column type="index" label="编号" width="80" align="center"></el-table-column>
        <el-table-column prop="username" label="用户姓名" align="center"></el-table-column>
        <el-table-column prop="email" label="用户邮箱" align="center"></el-table-column>
        <el-table-column prop="context" label="反馈内容" align="center"></el-table-column>
        <el-table-column prop="createTime" label="创建时间" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template #default="scope">
            <el-button link type="primary" :disabled="scope.row.level==40"
                       @click="management(scope.row.id)">处理</el-button>
            <el-button link type="primary" :disabled="scope.row.level==40"
                       @click="deleteUserFeedback(scope.row.feedbackId)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>


<script setup>
import {onMounted, ref} from "vue";
import axios from '@/util/request'
import qs from "qs";
import {ElMessage} from "element-plus";

//保存用户反馈
const feedBackArr = ref([]);
//用户反馈搜索
const select =()=>{
  //如果有查询条件,就根据后面拼接的条件查,没有条件默认加载所有用户数据
  axios.get('/v1/userFeedback/select')
      .then((response)=>{//回调函数中处理响应结果
        if(response.data.code == 2000){
          console.log(response.data.data);
          feedBackArr.value = response.data.data;//将后端响应数据装入用户数组中
          console.log(feedBackArr.value);
        }else{
          ElMessage.error(response.data.msg);
        }
      })
}
//用户反馈管理
const management =()=>{

}

//用户反馈删除
const deleteUserFeedback = (feedbackId)=>{
  console.log(feedbackId)
  if(confirm('您确认要删除这条反馈吗?')){
    axios.post('/v1/userFeedback/delete/'+feedbackId)
        .then((response)=>{
          if(response.data.code == 2000){
            ElMessage.success('删除成功!');
            select();//重新加载用户数据
          }else{
            ElMessage.error(response.data.msg);
          }
        })
  }

}
/* 页面一加载完毕,立即执行 */
onMounted(()=>{
  select();
})

</script>



<style scoped>

</style>